package com.blog.wu.myblog.rabbitmq;

import com.alibaba.fastjson.JSON;
import com.blog.wu.myblog.base.BaseService;
import com.blog.wu.myblog.entity.TestUser;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author wuyanshen
 * @Date 2018-12-27 9:31 AM
 * @Discription RabbitMq消费者
 */
//@Component
public class RabbitMqConsumer extends BaseService {

//    @RabbitListener(queues = "myblog-queue",containerFactory = "rabbitListenerContainerFactory")
    @RabbitListener(queues = "myblog-queue")
//    @RabbitHandler
    public void recive(Message message) {
        String msg = new String(message.getBody());
        TestUser testUser = JSON.parseObject(msg, TestUser.class);
        logger.info("我是消费者：我收到："+msg);
        logger.info("testUser类：{}  {}",testUser.getUsername(),testUser.getPwd());
    }


}
